package com.xbenben.demoroot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/demo/redis")
public class RedisDemoController {

    @Autowired
    private RedisTemplate<String, String> redisTemplate;

    @RequestMapping(value = "/save", method = RequestMethod.GET)
    public String sendRedis(@RequestParam("key") String key, @RequestParam("content") String content) {
        redisTemplate.opsForValue().set(key, content);
        return "ok --> "+key+"  -- >"+content;
    }

    @RequestMapping(value = "/del", method = RequestMethod.GET)
    public String sendRedis(@RequestParam("key") String key) {

        redisTemplate.delete(key);

        return "ok --> "+key+"";
    }



}
